package JZOffer;

import java.util.Arrays;

public class _6 {
    class Solution {
        public int minNumberInRotateArray(int[] array) {
            int temp1 = 0, temp2 = 0;
            temp1 = array[0];
            temp2 = array[1];
            array[0] = array[array.length-1];
            array[1] = array[array.length-2];
            array[array.length-1] = temp1;
            array[array.length-2] = temp2;
            return Arrays.stream(array).min().getAsInt();
        }
    }

    Solution getSolution() {
        return new Solution();
    }

    public static void main(String args[]) {
        _6 c = new _6();
        _6.Solution s = c.getSolution();
        int[] test = {1,2,3,4,5};
        int res = s.minNumberInRotateArray(test);
        System.out.println(res);
    }
}
